<?php
class Administrator_Model extends ORM {
	
	protected $table_name = 'admin';
	protected $primary_key = 'admin_id';
	protected $sorting = array('admin_id' => 'desc');
	
	public function get()
	{
		$this->db->select('*');
		$this->db->from($this->table_name);		
		$this->db->orderby($this->primary_key,'desc');
		$query = $this->db->get();
		return $query->result_array(false);
	}
    
	function update($id, $data)
	{		
		if(is_array($id)){
			$this->db->where_in($this->primary_key, $id);
		} else {
			$this->db->where($this->primary_key, $id);
		}	
		$result = $this->db->update($this->table_name, $data);		
		// Return
		if($result){
			return $id;
		} else {
			return false;
		}  
	}
	
	function getfromfield($wh,$field)
	{
		//get id row
		$this->db->select('*');
		$this->db->from($this->table_name);
		$this->db->where($field, $wh);
		$this->db->limit('1');
		
		$query = $this->db->get();
		// One row, match!
		return $query->result_array(false);
		//return $row[0];
	}
}
?>